<script setup lang="ts">
import { ref } from 'vue';

// 引入子页面组件
import TokenConfig from './jwtconfig.vue';
import OtherConfig from './otherconfig.vue';
import AccessConfig from './accessconfig.vue';

defineOptions({
  name: 'SystemConfig',
});

// 当前活跃的标签页
const activeTab = ref('token');

// 标签页配置
const tabs = [
  {
    label: '🔑 令牌设置',
    value: 'token',
  },
  {
    label: '🛡️ 访问控制',
    value: 'access',
  },
  {
    label: '⚙️ 其他设置',
    value: 'other',
  },
];
</script>

<template>
  <div class="system-config-container">
    <div class="config-drawer-content">
      <!-- 标签页切换器 -->
      <div class="config-tabs-header">
        <div class="config-tabs-nav">
          <div
            v-for="tab in tabs"
            :key="tab.value"
            :class="[
              'config-tab-item',
              { 'config-tab-item-active': activeTab === tab.value }
            ]"
            @click="activeTab = tab.value"
          >
            {{ tab.label }}
          </div>
        </div>
      </div>

      <!-- 内容区域 -->
      <div class="config-tabs-content">
        <div v-show="activeTab === 'token'" class="config-tab-pane">
          <TokenConfig />
        </div>
        <div v-show="activeTab === 'other'" class="config-tab-pane">
          <OtherConfig />
        </div>
        <div v-show="activeTab === 'access'" class="config-tab-pane">
          <AccessConfig />
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.system-config-container {
  background-color: hsl(var(--background-deep));
  min-height: 100vh;
  padding: 1rem;
}

.config-drawer-content {
  background-color: hsl(var(--card));
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* 标签页头部 */
.config-tabs-header {
  border-bottom: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  display: flex;
  justify-content: center;
}

.config-tabs-nav {
  display: inline-flex;
  position: relative;
  background-color: hsl(var(--accent));
  border-radius: 0.375rem;
  padding: 0.25rem;
  margin: 0.75rem auto;
  gap: 0.25rem;
}

.config-tab-item {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 0.25rem;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  user-select: none;
  position: relative;
  z-index: 1;
  color: hsl(var(--muted-foreground));
  min-width: auto;
}

.config-tab-item:hover {
  color: hsl(var(--foreground));
}

.config-tab-item-active {
  background-color: hsl(var(--popover));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

/* 内容区域 */
.config-tabs-content {
  background-color: hsl(var(--card));
}

.config-tab-pane {
  min-height: 350px;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* 深色主题通过CSS变量自动适配 */
</style>
